﻿/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A
 * copy of the license can be found at http://go.microsoft.com/fwlink/?LinkID=131993. If
 * you cannot locate the Microsoft Public License, please send an email to
 * mixon@microsoft.com. By using this source code in any fashion, you are agreeing to
 * be bound by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System.Windows;
using System.Windows.Controls;

namespace MIXOnline.Descry
{
    public partial class tee : UserControl
    {
        private int teeState = 1;
        public string currentState;
        public double TeeTop;
        public double TeeLeft;
        public double ObesityRate;

        public tee()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(tee_Loaded);
        }

        // get the correct initial state for tee when loaded
        // based on the set obesity rate
        private void tee_Loaded(object sender, RoutedEventArgs e)
        {
            SetTeeState();
            //GetTeeState();
            ChangeTee(currentState);
        }


        public void SetTeeState()
        {
            if (this.ObesityRate == 0) { teeState = 1; }
            else if (this.ObesityRate >= 1 && this.ObesityRate < 10) { teeState = 2; }
            else if (this.ObesityRate >= 10 && this.ObesityRate < 15) { teeState = 3; }
            else if (this.ObesityRate >= 15 && this.ObesityRate < 20) { teeState = 4; }
            else if (this.ObesityRate >= 20 && this.ObesityRate < 25) { teeState = 5; }
            else if (this.ObesityRate >= 25 && this.ObesityRate <= 30) { teeState = 6; }
            else if (this.ObesityRate > 30) { teeState = 7; }

            switch (teeState)
            {
                case 1:
                    currentState = "tee_1";
                    break;
                case 2:
                    currentState = "tee_2";
                    break;
                case 3:
                    currentState = "tee_3";
                    break;
                case 4:
                    currentState = "tee_4";
                    break;
                case 5:
                    currentState = "tee_5";
                    break;
                case 6:
                    currentState = "tee_6";
                    break;
                case 7:
                    currentState = "tee_7";
                    break;
            }
        }

        // publicly accessible function to change 
        // the tee shirt state
        public void ChangeTee(string whichTee)
        {
            VisualStateManager.GoToState(this, whichTee, false);
        }


        // generalized function to convert tee state 
        // # to Visual State Manager state name
        //private void GetTeeState()
        //{
        //    switch (teeState)
        //    {
        //        case 1:
        //            currentState = "tee_1";
        //            break;
        //        case 2:
        //            currentState = "tee_2";
        //            break;
        //        case 3:
        //            currentState = "tee_3";
        //            break;
        //        case 4:
        //            currentState = "tee_4";
        //            break;
        //        case 5:
        //            currentState = "tee_5";
        //            break;
        //        case 6:
        //            currentState = "tee_6";
        //            break;
        //        case 7:
        //            currentState = "tee_7";
        //            break;
        //    }
        //}


    }
}
